import request from '/@/utils/request';
export function login(data) {
	const param = {};
	param.UserID = data.username;
	param.Passwd = data.password;
	return request({
		url: API_URL_PRE + '/login.action',
		method: 'post',
		params: param,
	});
}

/**
 * 获取林栖云平台账户信息
 * @param {} token
 * @returns
 */
export function getInfo(token) {
	return request({
		url: API_URL_PRE + '/info',
		method: 'get',
		params: { token },
	});
}

/**
 * 退出登录
 * @returns
 */
export function logout() {
	return request({
		url: API_URL_PRE + '/logout.action',
		method: 'post',
	});
}

/**
 * 获取用户菜单权限
 * @returns
 */
export function getMenuPermissions() {
	const data = {};
	data.current = 1;
	data.limit = 400;
	return request({
		url: API_URL_PRE + '/userMenu.action',
		method: 'get',
		params: data,
	});
}

/**
 * 获取用户权限
 * @returns
 */
export function getBtnPermissions() {
	const data = {};
	data.current = 1;
	data.limit = 400;
	return request({
		url: API_URL_PRE + '/userButton.action',
		method: 'get',
		params: data,
	});
}

/*
 * 根据用户ID获取平台用户信息
 * @param {UserID} params
 * @returns
 * */
export function queryUserInfo(data) {
	return request({
		url: API_URL_PRE + '/queryUserInfo.action',
		method: 'post',
		params: data,
	});
}

/*
 * 增加平台登录用户
 * @param {User} params
 * @returns
 * */
export function addUserAccount(data) {
	return request({
		url: API_URL_PRE + '/addUserAccount.action',
		method: 'post',
		params: data,
	});
}

export function QueryEnterpriseMember(params) {
	return request({
		url: '/eslithe/QueryEnterpriseMember.action',
		method: 'post',
		params: params,
	});
}

export function QueryProjecRole(params) {
	return request({
		url: '/eslithe/QueryProjecRole.action',
		method: 'post',
		data: params,
	});
}

export function QueryProjectMember(params) {
	return request({
		url: '/eslithe/QueryProjectMember.action',
		method: 'post',
		params: params,
	});
}

export function AddProjectMember(params) {
	return request({
		url: '/eslithe/AddProjectMember.action',
		method: 'post',
		params: params,
	});
}

export function BatchAddProjectMember(params) {
	return request({
		url: '/eslithe/BatchAddProjectMember.action',
		method: 'post',
		data: { Records: params },
	});
}

export function updateProjectMember(params) {
	return request({
		url: '/eslithe/updateProjectMember.action',
		method: 'post',
		params: params,
	});
}

export function deleteProjectMember(params) {
	return request({
		url: '/eslithe/deleteProjectMember.action',
		method: 'post',
		params: params,
	});
}

export function updateUserInfo(params) {
	return request({
		url: '/eslithe/updateUserInfo.action',
		method: 'post',
		params: params,
	});
}

export function updateUserEnterpriseInfo(params) {
	return request({
		url: '/eslithe/updateUserEnterpriseInfo.action',
		method: 'post',
		params: params,
	});
}

export function deleteUserBelong(params) {
	return request({
		url: '/eslithe/deleteUserBelong.action',
		method: 'post',
		params: params,
	});
}
/**
 * 更新用户信息
 * @param {User} data
 * @returns
 */
export function updateUserInfoSelf(data) {
	return request({
		url: API_URL_PRE + '/updateUserInfoSelf.action',
		method: 'post',
		params: data,
	});
}

/**
 * 更新平台用户信息
 * @param {User} data
 * @returns
 */
export function updateUserInfomation(data) {
	return request({
		url: API_URL_PRE + '/updateUserInfomation.action',
		method: 'post',
		params: data,
	});
}

/**
 * 查询系统角色信息
 * @param
 * @returns
 */
export function queryRoles() {
	return request({
		url: `/${localStorage.getItem('projectCode')}/queryRoles.action`,
		method: 'post',
	});
}

export function queryRole(params) {
	return request({
		url: `/${localStorage.getItem('projectCode')}/queryRole.action`,
		method: 'post',
		params: params,
	});
}

export function addRole(params) {
	return request({
		url: `/${localStorage.getItem('projectCode')}/addRole.action`,
		method: 'post',
		params: params,
	});
}

export function updateRole(params) {
	return request({
		url: `/${localStorage.getItem('projectCode')}/updateRole.action`,
		method: 'post',
		params: params,
	});
}

export function deleteRole(params) {
	return request({
		url: `/${localStorage.getItem('projectCode')}/deleteRole.action`,
		method: 'post',
		params: params,
	});
}

export async function queryRoleFunc(params) {
	return request({
		url: '/role/queryRoleFunc.action',
		method: 'post',
		params: params,
	});
}

export async function queryFuncTree(params) {
	return request({
		url: '/eslithe/queryFuncTree.action',
		method: 'post',
		params: params,
	});
}

export async function delAllRoleFunc(params) {
	return request({
		url: `/${localStorage.getItem('projectCode')}/delAllRoleFunc.action`,
		method: 'post',
		params: params,
	});
}

export async function addRoleFuncList(params, data) {
	return request({
		url: `/${localStorage.getItem('projectCode')}/addRoleFuncList.action`,
		method: 'post',
		data: data,
		params: params,
	});
}
